// pages/organization/manager/index.js
import {
  getRidingEventsMyCreateApi
} from '../../../https/ridingEvents'
import {
  BASE_URL
} from '../../../constant/index'
Page({

  /**
   * 页面的初始数据
   */
  data: {
    BASE_URL,
    list: [],
    limit: 200,
    page: 1,
    total: 100
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    this.getData()
  },
  onShow() {
    this.setData({
      limit: 200,
      page: 1,
      total: 100
    })
    this.getData()
  },
  // 获取数据列表
  async getData() {
    const {
      page,
      limit
    } = this.data
    const getRes = await getRidingEventsMyCreateApi({
      page,
      limit
    })
    console.log(getRes)
    if (getRes.code == 200) {
      this.setData({
        list: getRes.data.list,
        total: getRes.data.total,
        page: getRes.data.page + 1,
        limit: getRes.data.limit,
      })
    }
  },
  // 跳转详情页面
  gotoDetail(e) {
    console.log(e)
    const docid = e.currentTarget.dataset.docid
    wx.navigateTo({
      url: '../detail/index?docid=' + docid,
    })
  },
  // 跳转创建页面
  gotoAdd() {
    wx.navigateTo({
      url: '../add/index',
    })
  }
})